package com.learn.spring.services;

import com.learn.spring.bean.Bean;
import com.learn.spring.dao.CustomerDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CustomerService extends Bean {
    public CustomerService() {
    }

    //    @Autowired //必填
    private CustomerDao dao;
    private String message;
    private String url;
    private String name;

    public void setUrl(String url) {
        this.url = url;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void printName() {
        System.out.println(" Customer name is " + this.name);
    }

    public void printUrl() {
        System.out.println(" Customer url is " + this.url);
    }

    public void printThrowException() {
        throw new IllegalArgumentException();
    }

    public CustomerService(CustomerDao dao) {
        this.dao = dao;
    }

    public String getMessage() {
        return message;
    }

    public CustomerDao getDao() {
        return dao;
    }

    public void setDao(CustomerDao dao) {
        this.dao = dao;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public String toString() {
        return "CustomerService{" +
                "dao=" + dao +
                ", message='" + message + '\'' +
                '}';
    }
}
